package com.bajiao.app.controller.account;

import cn.hutool.core.util.StrUtil;
import com.bajiao.app.base.AppBaseController;
import com.bajiao.common.api.vo.RestResult;
import com.bajiao.common.menu.ResultEnum;
import com.bajiao.common.web.entity.TableDataInfo;
import com.bajiao.service.account.AccountBillService;
import com.bajiao.vo.account.AccountBillVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * @description: 账单
 * @author: FanJq
 * @date: 2024-10-10
 */
@Slf4j
@Api(tags = "账户管理")
@RestController
@RequestMapping("/api/v1/bill")
public class RestAccountBillController extends AppBaseController {

    @Resource
    private AccountBillService billService;

    @GetMapping(value = "/page")
    @ApiOperation(value = "账单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue = "1", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", defaultValue = "10", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "filterDate", value = "日期(年-月-日)", dataType = "String"),
    })
    public RestResult<TableDataInfo<AccountBillVO>> getBillPage(@ModelAttribute("userId") String userId,
                                                                @RequestParam(value = "filterDate", required = false) String filterDate) {
        if (StrUtil.isBlank(userId))
            return tokenOverdue();
        startPage();
        List<AccountBillVO> billList = billService.getBillPage(userId, filterDate);
        return success(getDataTable(billList));
    }
}
